package sk.mucha.tracking;

import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.PropertyModel;

public abstract class PageTemplate extends WebPage {

	public PageTemplate() {
		add(new Label("pageTitle",new PropertyModel(this,"pageTitle")));
		add(new Link("logoutLink") {
			@Override
			public void onClick() {
				getSession().invalidateNow();
				getRequestCycle().setRedirect(true);
//				MySession.get().invalidateNow();
				setResponsePage(LoginPage.class);
			}
		});
//		addLinksToOtherPages();
	}
	
	protected void addLinksToOtherPages() {
		add(new BookmarkablePageLink("linkToProfile", UserProfilePage.class).setAutoEnable(true)
);
		add(new BookmarkablePageLink("linkToTracks", TracksPage.class).setAutoEnable(true)
);
		add(new BookmarkablePageLink("linkToSomething", SomethingPage.class).setAutoEnable(true)
);
	}
	
	// To be overridden by "child" templates
	public abstract String getPageTitle();

}
